<template>
    <div class="common-page page-home" v-loading.fullscreen="loading">
        <div class="common-page__body page-home__body">
            <div class="welcome">欢迎您~</div>
        </div>
    </div>
</template>

<script>
    import mixin from "../mixin";
    import { string, int } from "../util";
    export default {
        name: "page-home",
        title: "首页",
        nodes: [],
        childs: [],
        mixins: [mixin],
        data: () => ({
            loading: false,
        }),
        methods: {
            destroy() {
                if (this.loading) return;
                return true;
            },
            init() {
                if (this.loading) return;
                this.loading = true;
                this.$root.$refs.navbar.init();
                this.plugins.user.call(async () => {
                    let res = await this.plugins.user.init();
                    if (res.code === 0) { }
                    return res;
                }).then((res) => {
                    this.loading = false;
                    this.$root.$refs.navbar.init();
                    if (res.code === 0) {

                    } else if (res.code === 2) {
                        this.$root.$refs.navbar.login();
                    } else {
                        this.plugins.modal.alert("页面加载失败", res.code + "：" + res.msg, "error");
                    }
                });
            },
        },
    };
</script>

<style lang="scss">
    .page-home {
        overflow: hidden;
    }

    .page-home__body {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

        & > .welcome {
            flex: 0 0 auto;
            color: #aaa;
            font-size: 32px;
            font-style: italic;
            line-height: 40px;
        }
    }
</style>